package com.example.app;

import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;
import android.widget.Button;
import android.widget.ImageButton;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ActionBar actionBar = getActionBar();
        actionBar.hide();

        if (savedInstanceState == null) {
            getFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment())
                    .commit();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public void onBackPressed(){
        super.onBackPressed();
        overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container, false);
            Button mobaBtn = (Button)rootView.findViewById(R.id.moba_button);
            mobaBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(MainActivity.this, NewsListActivity.class);
                    Bundle extras = new Bundle();
                    extras.putInt("TAB", 0);
                    intent.putExtras(extras);
                    startActivity(intent);
                    overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
                }
            });

            Button rtsBtn = (Button)rootView.findViewById(R.id.rts_button);
            rtsBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(MainActivity.this, NewsListActivity.class);
                    Bundle extras = new Bundle();
                    extras.putInt("TAB", 1);
                    intent.putExtras(extras);
                    startActivity(intent);
                    overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
                }
            });

            Button fpsBtn = (Button)rootView.findViewById(R.id.fps_button);
            fpsBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(MainActivity.this, NewsListActivity.class);
                    Bundle extras = new Bundle();
                    extras.putInt("TAB", 2);
                    intent.putExtras(extras);
                    startActivity(intent);
                    overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
                }
            });

            Button fightBtn = (Button)rootView.findViewById(R.id.fight_button);
            fightBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(MainActivity.this, NewsListActivity.class);
                    Bundle extras = new Bundle();
                    extras.putInt("TAB", 3);
                    intent.putExtras(extras);
                    startActivity(intent);
                    overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
                }
            });

            Button newhereBtn = (Button)rootView.findViewById(R.id.newhere_button);
            newhereBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(MainActivity.this, novoAqui.class);
                    Bundle extras = new Bundle();
                    extras.putInt("helper", 0);
                    intent.putExtras(extras);

                    startActivity(intent);
                }
            });

            ImageButton mobaHelperBtn = (ImageButton)rootView.findViewById(R.id.moba_help_button);
            mobaHelperBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(MainActivity.this, novoAqui.class);
                    Bundle extras = new Bundle();
                    extras.putInt("helper", 1);
                    intent.putExtras(extras);

                    startActivity(intent);
                }
            });

            ImageButton rtsHelperBtn = (ImageButton)rootView.findViewById(R.id.rts_help_button);
            rtsHelperBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(MainActivity.this, novoAqui.class);
                    Bundle extras = new Bundle();
                    extras.putInt("helper", 2);
                    intent.putExtras(extras);

                    startActivity(intent);
                }
            });

            ImageButton fpsHelperBtn = (ImageButton)rootView.findViewById(R.id.fps_help_button);
            fpsHelperBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(MainActivity.this, novoAqui.class);
                    Bundle extras = new Bundle();
                    extras.putInt("helper", 3);
                    intent.putExtras(extras);

                    startActivity(intent);
                }
            });

            ImageButton fightingHelperBtn = (ImageButton)rootView.findViewById(R.id.fight_help_button);
            fightingHelperBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(MainActivity.this, novoAqui.class);
                    Bundle extras = new Bundle();
                    extras.putInt("helper", 4);
                    intent.putExtras(extras);

                    startActivity(intent);
                }
            });
            return rootView;
        }
    }

}
